package com.mapper;

import com.domain.Person;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface Personmaper {


    @Select("select * from mybatis.person")
    @Results(value = {
//            //id字段默认为false，表示不是主键
//            //column表示数据库表字段，property表示实体类属性名。
            @Result(id = true,column = "id",property = "id"),
            @Result(column = "name",property = "name"),
            @Result(column = "password",property = "password"),
            @Result(column = "create_time",property = "create_time"),
            @Result(column = "update_time",property = "update_time"),
    })

    List<Person> findallperson();
@Insert("insert into mybatis.person(id,name,password,create_time,update_time) value (#{id},#{name},#{password},#{create_time},#{update_time})")
    void addperson(Person person);

    @Select("select * from mybatis.person where id like  CONCAT('%',#{param01},'%') and name like  CONCAT('%',#{param02},'%')")
    @Results(value = {
//            //id字段默认为false，表示不是主键
//            //column表示数据库表字段，property表示实体类属性名。
            @Result(id = true,column = "id",property = "id"),
            @Result(column = "name",property = "name"),
            @Result(column = "password",property = "password"),
            @Result(column = "create_time",property = "create_time"),
            @Result(column = "update_time",property = "update_time"),
    })
List<Person> searchall(@Param("param01") String id, @Param("param02") String name);


@Update("update mybatis.person set name=#{param02}, password=#{param03} where id=#{param01}")
   public void  editperson(@Param("param01") String id,@Param("param02") String name,@Param("param03") String password);


@Delete("delete from mybatis.person where id=#{param01}")
   void delperson(@Param("param01") String id);




}
